package com.smh.aiagent.model.vo;

import com.smh.aiagent.enums.HttpStatus;
import lombok.Data;

/**
 * @author shiminghui
 * @date 2025/5/30 15:45
 * @description: TODO
 */
@Data
public class ResultVO<T> {
    private Integer code;
    private String message;
    private T data;

    public ResultVO() {
    }

    public ResultVO(Integer code, String message, T data) {
        this.code = code;
        this.message = message;
        this.data = data;
    }

    public ResultVO(HttpStatus httpStatus, T data) {
        this.code = httpStatus.getCode();
        this.message = httpStatus.getMessage();
        this.data = data;
    }

    public ResultVO(HttpStatus httpStatus) {
        this.code = httpStatus.getCode();
        this.message = httpStatus.getMessage();
    }

    public static <T> ResultVO<T> success(T data) {
        return new ResultVO<>(HttpStatus.SUCCESS, data);
    }

    public static <T> ResultVO<T> success() {
        return new ResultVO<>(HttpStatus.SUCCESS);
    }

    public static <T> ResultVO<T> success(Integer code, String message, T data) {
        return new ResultVO<>(code, message, data);
    }

    public static <T> ResultVO<T> fail(T data) {
        return new ResultVO<>(HttpStatus.FAIL, data);
    }

    public static <T> ResultVO<T> fail() {
        return new ResultVO<>(HttpStatus.FAIL);
    }

    public static <T> ResultVO<T> fail(Integer code, String message, T data) {
        return new ResultVO<>(code, message, data);
    }

    public static <T> ResultVO<T> fail(Integer code, String message) {
        return new ResultVO<>(code, message, null);
    }

    public static <T> ResultVO<T> of(HttpStatus httpStatus, T data) {
        return new ResultVO<>(httpStatus, data);
    }

    public static <T> ResultVO<T> of(HttpStatus httpStatus) {
        return new ResultVO<>(httpStatus);
    }

}
